//###############
//FILE : NameContainFileSession.java
//WRITER : Daniel Lowengrub, daniel_i_l, 320687098
//EXERCISE : oop ex3 2011
//DESCRIPTION:
//See below
//###############

package oop.ex3.protocol.sessions;

import oop.ex3.protocol.messages.ContainFileMsg;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import oop.ex3.exceptions.InvalidMessageException;

/**
 * This gets a contain file notification from a FM.
 * @author daniel
 */
public class NameContainFileSession extends NameToFileSession {
    private String _fileName;

    /**
	 * Create a new session.
	 */
    public NameContainFileSession() {
        super(new ContainFileMsg());
    }

    /**
     * Get the file name that was added.
     * @return
     */
    public String getFileName() {
        return _fileName;
    }

    @Override
    protected boolean specExecuteSession(DataInputStream inputStream, DataOutputStream outputStream) throws IOException, InvalidMessageException {
        ContainFileMsg containFile = new ContainFileMsg();
        containFile.receive(inputStream);
        _done.send(outputStream);
        
        _fileName = containFile.getFileName();

        return true;
    }

}
